<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width='device-width', initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="change">show/hide</button>
        <keep-alive>
            <list v-if="isShow"></list>
        </keep-alive>
    </div>
    <script src="./vue.js"></script>
    <script>
        let List = {
            template:`
                <div>
                    <input v-model="msg"/>   
                </div>
            `,
            data(){
                return {
                    msg:""
                }
            },
            created(){
                console.log("实例已经创建")
                // 
            },
            beforeDestroy(){
                console.log("销毁之前")
            },
            activated(){
                console.log("激活")
                // 在这里调用需要局部刷新ajax请求函数
            },
            deactivated(){
                console.log("隐藏了")
            }
        }
        Vue.component("List",List)
        let vm = new Vue({
            el:"#app",
            data:{
                isShow:true
            },
            methods:{
                change(){
                    this.isShow = !this.isShow
                }
            }
        })
    </script>
</body>
</html>